package com.artisan.web.utils;



import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;

import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

/**
 * Created by xierongxian on 2016/4/12.
 * 发送手机验证码
 */

public class SendMsg {
    public static String getVerifyCode(final String phone,final String code){
        TaobaoClient client = new DefaultTaobaoClient("http://gw.api.taobao.com/router/rest",
                "24527757", "188182ad28fcc6b2aaa73557fd60de21");
        AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
        req.setExtend( "" );
        req.setSmsType( "normal" );
        req.setSmsFreeSignName( "小工匠" );
        req.setSmsParamString( "{number:'"+code+"'}" );
        req.setRecNum( phone );
        req.setSmsTemplateCode( "SMS_75080013" );
        AlibabaAliqinFcSmsNumSendResponse rsp = null;
        try {
            rsp = client.execute(req);
        } catch (ApiException e) {
            e.printStackTrace();
        }
        return rsp.getResult().getErrCode();}
    public  static void main(String[]args){
        getVerifyCode("17366333833","1234");


    }
}
